//
//  NetWorkState.m
//  判断网络
//
//  Created by lanou on 16/1/14.
//  Copyright (c) 2016年 冯文秀. All rights reserved.
//

#import "NetWorkState.h"
#import "Reachability.h"
@implementation NetWorkState
// 判断网络类 写成单例给多个界面使用
+ (NetWorkState *)shareInstance
{
    static NetWorkState *net = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        net = [[NetWorkState alloc]init];
    });
    return net;
}

// 返回yes有网 no没有网
- (BOOL)reachability
{
    Reachability *reach = [Reachability reachabilityWithHostName:@"www.baidu.com"];
    switch ([reach currentReachabilityStatus]) {
        case NotReachable:
            return NO;
            break;
        case ReachableViaWWAN:
            return YES;
            break;
        case ReachableViaWiFi:
            return YES;
        default:
            break;
    }
}
@end
